plot_condition = function(condition) {
fname = paste("../data/0_pre_test-cond", condition, "-trials.csv", sep="")
d = read.csv(fname)
drops <- c("modal1","rating1")
d2 = d[ , !(names(d) %in% drops)]
setnames(d2, old=c("rating2","modal2"), new=c("rating", "modal"))
drops <- c("modal2","rating2")
d3 = d[ , !(names(d) %in% drops)]
setnames(d3, old=c("rating1","modal1"), new=c("rating", "modal"))
drops <- c("modal2", "rating2", "modal1", "rating1")
d4 = d[ , !(names(d) %in% drops)]
d4$rating = d4$rating_other
d4$modal = "other"
d = rbind(d2, d3, d4)
d$modal = factor(d$modal)
d$percentage_blue_f = factor(d$percentage_blue)
d_blue = d %>% filter(., grepl("blue", sentence2))
d_orange = d %>% filter(., grepl("orange", sentence2))
#ggplot(d_orange, aes(x=percentage_blue, y=rating)) + geom_point(aes(col=modal)) +
# geom_smooth(aes(col=modal))
#ggplot(d_blue, aes(x=percentage_blue, y=rating)) + geom_point(aes(col=modal)) + geom_smooth(aes(col=modal))
d_orange_reverse = d_orange
d_orange_reverse$percentage_blue = 100-d_orange$percentage_blue
d_comparison = rbind(d_blue, d_orange_reverse)
d_comparison$blue= grepl("blue", d_comparison$sentence2)
d_comparison$percentage_blue_f = factor(d_comparison$percentage_blue)
#p1 = ggplot(d_comparison, aes(x=percentage_blue, y=rating)) + geom_point(aes(col=modal)) + stat_smooth(aes(col=modal, fill=modal), method = 'loess', geom="area", alpha=0.5) + ggtitle(d$pair[1]) + xlab("percentage")
p1 = ggplot(d_comparison, aes(x=percentage_blue, y=rating)) + stat_smooth(aes(col=modal, fill=modal), method = 'loess', geom="area", alpha=0.5) + ggtitle(d$pair[1]) + xlab("percentage")
p2 = ggplot(d_comparison, aes(x=percentage_blue_f, y=rating, fill=modal)) +
geom_boxplot() +
ggtitle(d$pair[1]) + xlab("percentage")
return(list("p1" = p1, "p2" = p2))
}
for (i in 0:20) {
ps = plot_condition(i)
plot(ps$p1)
plot(ps$p2)
}










































ps = plot_condition("5_2")
plot(ps$p1)

plot(ps$p2)
